package de.pass.ch.datastr;

public class PQueueNodeLocalSearch extends PQueueNode {

	private int _hops;

	public PQueueNodeLocalSearch() {
		_hops = 0;
		setTarget(false);
		setEliminated(false);
	}

	/** If node is a target of the local search */
	@Override
	public boolean isTarget() {
		return (_hops & Integer.MIN_VALUE) != 0;
	}

	@Override
	public void setTarget(boolean value) {
		if (value) {
			_hops |= Integer.MIN_VALUE;
		} else {
			_hops &= Integer.MAX_VALUE;
		}
	}

	/** If node is already elminated / contracted. */
	@Override
	public boolean isEliminated() {
		return (_hops & (Integer.MIN_VALUE >>> 1)) != 0;
	}

	@Override
	public void setEliminated(boolean value) {
		if (value) {
			_hops |= (Integer.MIN_VALUE >>> 1);
		} else {
			_hops &= ~(Integer.MIN_VALUE >>> 1);
		}
	}

	/** Hops (edges) to the source node. */
	@Override
	public int hops() {
		return _hops & (Integer.MAX_VALUE >> 1);
	}

	@Override
	public void setHops(int v) {
		_hops = (_hops & (Integer.MIN_VALUE >> 1))
				| (v & Integer.MAX_VALUE >> 1);
	}
}
